﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AirConditionControl.Controls
{
    public partial class UAirControl : UserControl
    {
        public UAirControl()
        {
            InitializeComponent();
            this.Margin = new Padding(6, 6, 3, 3);
            this.Size = new Size(300, 180);
            uBtn1.Click += UBtn1_Click;
        }

        private string stateParamName;
        [Category("自定义属性")]
        [Description("状态参数名称")]
        public string StateParamName
        {
            get { return stateParamName; }
            set { stateParamName = value; }
        }

        private string temperParamName;
        [Category("自定义属性")]
        [Description("温度参数名称")]
        public string TemperParamName
        {
            get { return temperParamName; }
            set { temperParamName = value; }
        }

        private string runState = "OFF";
        public string RunState
        {
            get { return runState; }
            set
            {
                runState = value;
                stateLb1.Text = runState;
            }
        }


        private bool state = false;
        [Category("自定义属性")]
        [Description("启停状态")]
        public bool State
        {
            get { return state; }
            set
            {
                state = value;
                uBtn1.IsCheck = state;
                RunState = state ? "ON" : "OFF";
            }
        }


        private string deviceName = "1#设备";
        [Category("自定义属性")]
        [Description("设备名称")]
        public string DeviceName
        {
            get { return deviceName; }
            set
            {
                deviceName = value;
                numLb1.Text = deviceName;
            }
        }

        private string temperature = "0℃";
        [Category("自定义属性")]
        [Description("温度值")]
        public string Temperature
        {
            get { return temperature; }
            set
            {
                temperature = value;
                temperLb1.Text = temperature;
            }
        }

        public event EventHandler ChangeStateEvent;

        private void UBtn1_Click(object? sender, EventArgs e)
        {
            ChangeStateEvent?.Invoke(this, e);
        }
    }
}
